const {Menu} = require('../db/model/index')
const {Op} = require('sequelize')

const getMenuList = async (ids) => {
  let where = {}
  if (ids !== 'all') {
    where = {
      id: {
        [Op.in]: ids.split(',')
      }
    }
  }

  const result = await Menu.findAll({
    where
  })

  const data = result.map(item => item.dataValues)

  return data
}

module.exports = {
  getMenuList
}
